package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhSocre;
import com.laowang.project.system.service.MyCyhSocreService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 积分规则Controller
 *
 * @author laowang
 * @date 2023-05-31
 */
@Api(tags = "积分规则接口")
@RestController
@RequestMapping("/score")
public class MyCyhSocreController extends BaseController {

    @Autowired
    private MyCyhSocreService myCyhSocreService;


    /**
     * 查询积分规则列表
     */
    @ApiOperation(value = "查询积分规则列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:score:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyCyhSocre myCyhSocre) {
        startPage();
        List<MyCyhSocre> list = myCyhSocreService.selectMyCyhSocreList(myCyhSocre);
        return getDataTable(list);
    }

    /**
     * 导出积分规则列表
     */
    @ApiOperation(value = "导出积分规则列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:score:export')")
    @Log(title = "积分规则", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhSocre myCyhSocre) {
        List<MyCyhSocre> list = myCyhSocreService.selectMyCyhSocreList(myCyhSocre);
        ExcelUtil<MyCyhSocre> util = new ExcelUtil<MyCyhSocre>(MyCyhSocre.class);
        return util.exportExcel(list, "score");
    }

    /**
     * 获取积分规则详细信息
     */
    @ApiOperation(value = "获取积分规则详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('system:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhSocreService.selectMyCyhSocreById(id));
    }

    /**
     * 新增积分规则
     */
    @ApiOperation(value = "新增积分规则",notes = "")
    @PreAuthorize("@ss.hasPermi('system:score:add')")
    @Log(title = "积分规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhSocre myCyhSocre) {
        return toAjax(myCyhSocreService.insertMyCyhSocre(myCyhSocre));
    }

    /**
     * 修改积分规则
     */
    @ApiOperation(value = "修改积分规则",notes = "")
    @PreAuthorize("@ss.hasPermi('system:score:edit')")
    @Log(title = "积分规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhSocre myCyhSocre) {
        return toAjax(myCyhSocreService.updateMyCyhSocre(myCyhSocre));
    }

    /**
     * 删除积分规则
     */
    @ApiOperation(value = "删除积分规则",notes = "")
    @PreAuthorize("@ss.hasPermi('system:score:remove')")
    @Log(title = "积分规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhSocreService.deleteMyCyhSocreByIds(ids));
    }
}
